<?php
foreach ($items as $item) {
    ?>
    <div class="goods-rank">
        <img src="<?= $item['image_url'] ?>@100w"/>
        <div class="goods-news">
            <?php
            if ($item['is_crossborder'] == 1) {
                ?>
                <p class="kj">跨境</p>
                <?php
            }
            ?>
            <p><?= $item['name'] ?></p>
            <p class="rmb" style="display: block;">￥<span><?= $item['selling_price'] ?></span></p>
            <input type="button" class="details-btn" value="详情" data-toggle="modal" href="#productDetail" data-goods-code="<?= $item['code'] ?>"/>
        </div>
    </div>

    <?php
}

if (count($items) > 0) {
    ?>

    <div aria-hidden="true" role="dialog" tabindex="-1" id="productDetail" class="modal">
        <div class="modal-dialog modal-lg">
            <div class="modal-content">
                <div class="modal-header">
                    <button aria-hidden="true" data-dismiss="modal" class="close" type="button">×</button>
                    <h5 class="modal-title">产品详情</h5>
                </div>
                <div id="goodsDetailContent" class="modal-body" style="overflow-y: auto; width: 15.5rem;">
                </div>
                <div class="modal-footer">
                    <button class="btn btn-default" data-dismiss="modal">关闭</button>
                </div>
            </div>
        </div>
    </div>

    <script type="application/javascript">
        $(function () {
            var height = $(window).height();
            $('#goodsDetailContent').css('max-height', height - 170);
            $('#productDetail').on('show.bs.modal', function (e) {
                $("#goodsDetailContent").html('正在加载数据....');
                var orderCode = e.relatedTarget.attributes['data-goods-code'].value;
                requestJson('mobile-card-goods-show-detail-handler', {code: orderCode}, true, function (html) {
                    $("#goodsDetailContent").html(html.data);
                });
            });
        });
    </script>
    <?php
}
?>